package com.ft.dao;

import com.ft.domain.Workorder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author com/ft
 * @since 2022-08-24
 */
@Mapper
public interface WorkorderDao extends BaseMapper<Workorder> {

    /**
     * 创建订单
     * @param order 添加的订单对象
     * @return 受影响的行数
     */
    @Insert("insert into workorder(id,type,state,title,price,content,order_img,remarks,contacts,contacts_phone,contacts_address," +
            "issue_user,pay_type,hide_name) values(#{id},#{type},#{state},#{title},#{price},#{content},#{order_img}," +
            "#{remarks},#{contacts},#{contacts_phone},#{contacts_address},#{issue_user},#{pay_type},#{hide_name})")
    public int createWorkOrder(Workorder order);

    /**
     * 根据订单id查询订单信息
     * @param id 订单id
     * @return 订单对象
     */
    @Select("select * from workorder where id =#{id}")
    public Workorder selectWorkOrder(Long id);

    /**
     * 查询指定字段的数据用于微信支付
     * @param id 订单id
     * @return 订单对象
     */
    @Select("select id,title,price from workorder where id =#{id}")
    public Workorder selectWorkOrderToPay(Long id);
}
